package zhr.chapter8;

import java.util.HashSet;
import java.util.Iterator;

public class Example8_9 {
    public static void main(String[] args) {
        //HashSet散列表
        HashSet<Integer> hashSet1 = new HashSet<>();
        hashSet1.add(97);
        hashSet1.add(123);
        hashSet1.add(22);
        hashSet1.add(4);
        hashSet1.add(69);
        hashSet1.remove(69);
        hashSet1.add(100);
        System.out.println(hashSet1.contains(100));
        show(hashSet1);
        System.out.println();
    }

    public static void show(HashSet<Integer> collection) {
        Iterator<Integer> it = collection.iterator();
        for (Object o : collection) {
            System.out.println(it.next() + " ");
        }
        System.out.println();
    }
}
